package com.lagou.util;

import java.util.function.Consumer;

/**
 * @author: wudong
 * @create: 2021-05-27 18:42
 **/
public class ClassUtil {
    public static void findAllClass(Class<?> aClass, Consumer<Class<?>> classConsumer){
        if(aClass == null || aClass.equals(Object.class)){
            return;
        }

        Class<?> superclass = aClass.getSuperclass();
        if(superclass != null && !superclass.equals(Object.class)){
            classConsumer.accept(superclass);
            findAllClass(superclass,classConsumer);
        }

        Class<?>[] interfaces = aClass.getInterfaces();
        if(interfaces == null){
            return;
        }
        for (Class<?> anInterface : interfaces) {
            classConsumer.accept(anInterface);
            findAllClass(anInterface,classConsumer);
        }
    }
}
